<%@page import="org.json.JSONObject"%>
<%@page import="org.json.JSONArray"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<% 
	JSONArray jsonA = (JSONArray)request.getAttribute("array");
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="ajax.js"></script>

<title>COMMANDE</title>
</head>


<body>
<center>
<h1>CATALOGUE</h1>
<form ACTION="" METHOD='POST'>
<INPUT TYPE='hidden' value='session.getAttribute("codeLivraison")' id='loc'/>
<INPUT TYPE='hidden' NAME='comingFrom' value='order' SIZE='30' />
<%

%>
<table border="1px">
	<tr>
		<th>Code produit</th>
		<th>Libellé produit</th>
		<th>Quantité</th>
		<th>Date livraison</th>
		<th>Prix</th>
		<th>Note</th>
	</tr>
	<% 
	JSONArray bookedJson;
	Integer location = (Integer)session.getAttribute("codeLivraison");
	out.println("<p id='session' value=\'"+location+"\'>Bienvenue sur le site "+location+"</p>");
	for(int i=0;i<jsonA.length();i++)
			{
				JSONObject json = (JSONObject) jsonA.getJSONObject(i);	
				int id = json.getInt("productId");
				
				out.println("<tr>");
				
				out.println("<script type='text/javascript'>var jSon = "+json+"</script>");
				out.println("<td> <input type='hidden' value = \'"+json.getInt("productId")+"\' name ='productId' id=\'productId"+id+"\' />"+json.getInt("productId")+"</td>");
				out.println("<td>"+json.getString("productName")+"</td>");
				out.println("<td><input type='text' name=\'quantity"+id+"\' id=\'quantity"+id+"\' value='0' size='5' onchange='delay("+id+","+location+");' ></input></td>");
				out.println("<td NAME='delay' id=\'delay"+id+"\' SIZE='5'></td>");
				out.println("<td NAME='price' id=\'price"+id+"\' SIZE='5'></td>");
				out.println("<td NAME='note' id=\'note"+id+"\' SIZE=''></td>");
				out.println("<td><input type='hidden' id=\'bookedJson"+id+"\' ></input></td>");
				out.println("</tr>");
				
			}
	%> 
	
	<!--  <tr>
		<td>Prix TOTAL :</td>
		<td id='totalprice' ></td>
		<td>Délai total de livraison :</td>
		<td id='totaldelay' ></td>
	</tr>-->
	<tr>
		<td></td>
		<td><INPUT TYPE='SUBMIT' VALUE='Valider' /></td>
		<td><INPUT TYPE='SUBMIT' VALUE='Annuler' /></td>
	</tr>
</table>
</form>
<p id='test'></p>
</center>
<form action="" method='POST'>
	<INPUT TYPE='hidden' NAME='comingFrom' value='raz' SIZE='30' />
	<INPUT TYPE='SUBMIT' VALUE='RAZ BDD' />
</form>
</body>
</html>